import request from '@/utils/request';
import { IStudentParams, IStudentResponse, ISaveStudentParams, IUpdateStudentParams } from '@/typings/student';
import { IAllProps } from '@/typings/types';

const access_token = sessionStorage.getItem('token');

//获取学生信息 + 查询单个学生资料列表
export async function getStudentList(params?: IStudentParams): Promise<IStudentResponse> {
  // console.log(params);
  return request('/api2/studentInfo/selectStudentInfoList', {
    // method:'POST',
    headers: {
      access_token,
    },
    params,
  });
}

//根据院系ID查询专业
export async function getspecialtyList(facultyId: string) {
  // console.log(params);
  return request('/api2/school/getSchoolSpecialListByFacultyId', {
    // method:'POST',
    headers: {
      access_token,
    },
    params: { facultyId },
  });
}

//新增学生信息
export async function saveStudentInfo(params: ISaveStudentParams) {
  return request('/api2/studentInfo/saveStudentInfo', {
    method: 'POST',
    headers: {
      access_token,
    },
    data: params,
  });
}


//删除学生信息
export async function deleteStudentInfoByIds(ids: number) {
  return request('/api2/studentInfo/deleteStudentInfoByIds', {
    method: 'DELETE',
    headers: {
      access_token,
    },
    params: {
      ids,
    },
  });
}

//更新
export async function updateStudentInfo(params: IUpdateStudentParams) {
  return request('/api2studentInfo/updateStudentInfo', {
    method: 'POST',
    headers: {
      access_token,
    },
    data: params,
  });
}
